<?php
/**
 * Description:
 * Author: walkskyer
 * Email:zwj_work@qq.com
 * Date: 2015/2/2
 * Time: 14:29
 */

namespace app\controllers;

use app\components\FrontCtrl;
use yii\data\Pagination;
use app\models\Country;


class CountryController extends FrontCtrl{
    public function actionIndex(){
        $query=Country::find();
        $pagination = new Pagination([
            'defaultPageSize'=>5,
            'totalCount'=>$query->count(),
        ]);
        $countries=$query->orderBy('name')
            ->offset($pagination->offset)
            ->limit($pagination->limit)
            ->all();
        return $this->render('index',[
            'countries'=>$countries,
            'pagination'=>$pagination
        ]);
    }
}